package com.controller;

import com.model.HotBarrage;
import com.model.Sort;
import com.model.VideoBarrage;
import com.server.VideoBarrageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api("指定BV号弹幕")
    @RestController
    @RequestMapping("/videoBarrage")
    public class VideoBarrageController {

        @Autowired
        private VideoBarrageService videoBarrageService;

        @CrossOrigin
        @RequestMapping(value = "/addVideoBarrage", produces = "application/json;charset=utf-8", method = RequestMethod.PUT)
        public int insertVideoBarrage(@RequestBody VideoBarrage videoBarrage){
            System.out.println("进入弹幕添加方法");
            return videoBarrageService.insertVideoBarrage(videoBarrage);
        }

        @CrossOrigin
        @RequestMapping(value = "/getVideoBarrage", produces = "application/json;charset=utf-8", method = RequestMethod.GET)
        public VideoBarrage getVideoBarrage(String bv){
            System.out.println("进入根据BV号查找弹幕信息, 主键为: " + bv);
            return videoBarrageService.getVideoBarrage(bv);
        }

    @CrossOrigin
    @RequestMapping(value = "/updateVideoBarrage", produces = "application/json;charset=utf-8", method = RequestMethod.PUT)
    public int updateVideoBarrage(@RequestBody VideoBarrage videoBarrage){
        System.out.println("进入弹幕修改方法, 修改的主键为: " + videoBarrage.getId());
        return videoBarrageService.updateVideoBarrage(videoBarrage);
    }

    @CrossOrigin
    @RequestMapping(value = "/deleteVideoBarrage", produces = "application/json;charset=utf-8", method = RequestMethod.GET)
    public int deleteVideoBarrage(int id){
        System.out.println("进入弹幕删除方法, 主键为" + id);
        return videoBarrageService.deleteVideoBarrage(id);
    }

    @CrossOrigin
    @RequestMapping(value = "/getAllVideoBarrage", produces = "application/json;charset=utf-8", method = RequestMethod.PUT)
    public List<VideoBarrage> getAllVideoBarrage(@RequestBody VideoBarrage videoBarrage){
        System.out.println("进入弹幕查询方法");
        return videoBarrageService.getAllVideoBarrage(videoBarrage);
    }

    @CrossOrigin
    @RequestMapping(value = "/getContents", produces = "application/json;charset=utf-8", method = RequestMethod.GET)
    public List<String> videoBarrageContent(String bvid){
        System.out.println("进入获取弹幕内容方法, bv号为: " + bvid);
        return videoBarrageService.videoBarrageContent(bvid);
    }
    @ApiOperation(value = "重复弹幕排序")
    @GetMapping("/barrageSort")
    @CrossOrigin
    public List<Sort> barrageSort() {
        return videoBarrageService.barrageSort();
    }

    @ApiOperation(value = "弹幕bv号排序")
    @GetMapping("/bvSort")
    @CrossOrigin
    public List<Sort> bvSort() {
        return videoBarrageService.bvSort();
    }
    }



